package com.comm.db.dao;

import java.util.List;

import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.criterion.Example;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.comm.db.pojo.RResumebasictable;

/**
 * A data access object (DAO) providing persistence and search support for
 * RResumebasictable entities. Transaction control of the save(), update() and
 * delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see com.comm.db.pojo.RResumebasictable
 * @author MyEclipse Persistence Tools
 */

public class ResumebasictableDAO extends BaseHibernateDAO {
	private static final Logger log = LoggerFactory
			.getLogger(ResumebasictableDAO.class);
	// property constants
	public static final String USER_ID = "userId";
	public static final String USER_NAME = "userName";
	public static final String BIRTH_DAY = "birthDay";
	public static final String AGE = "age";
	public static final String MARRIED = "married";
	public static final String EXPERIENCE_TIME_VAL = "experienceTimeVal";
	public static final String HIGHEST_DEGREE = "highestDegree";
	public static final String ADDRESS = "address";
	public static final String COUNTRY = "country";
	public static final String NATIONALITY = "nationality";
	public static final String HOME_PHONE = "homePhone";
	public static final String COMPANY_PHONE = "companyPhone";
	public static final String MSNORQQ = "msnorqq";
	public static final String EMAIL = "email";
	public static final String HOBBIES = "hobbies";
	public static final String PRIZE = "prize";
	public static final String JOB_INTEREST = "jobInterest";
	public static final String CERTIFICATE_NAME = "certificateName";
	public static final String INDUSTRY_NAME = "industryName";
	public static final String LANGUAGE_NAME = "languageName";
	public static final String MAJOR_NAME = "majorName";
	public static final String POSITION_NAME = "positionName";
	public static final String FILL_USER_ID = "fillUserId";
	public static final String FILL_USER = "fillUser";
	public static final String LAST_EDIT_USER_ID = "lastEditUserId";
	public static final String LAST_EDIT_USER = "lastEditUser";
	public static final String FILL_DATE = "fillDate";
	public static final String LAST_EDIT_TIME = "lastEditTime";
	public static final String DEL_TAG = "delTag";
	public static final String RESUME_LOCK = "resumeLock";
	public static final String COMPANY_NAME = "companyName";
	public static final String CURRENT_COMPANYINFO = "currentCompanyinfo";
	public static final String CVID = "cvid";
	public static final String CERTTYPE = "certtype";
	public static final String CERTNO = "certno";
	public static final String MOBILE = "mobile";
	public static final String FROM_ID = "fromId";
	public static final String CURRENT_SALARY = "currentSalary";
	public static final String WORK_EXPERIENCE = "workExperience";
	public static final String EDU = "edu";
	public static final String LANGUAGE_SKILL = "languageSkill";
	public static final String IT_SKILL = "itSkill";
	public static final String PROJECT_EXPERIENCE = "projectExperience";
	public static final String SELF_ASSESSMENT = "selfAssessment";
	public static final String TRAINER = "trainer";
	public static final String OTHERS = "others";
	public static final String RESUME_LANGUAGE = "resumeLanguage";
	public static final String WEIBO = "weibo";
	public static final String SEX = "sex";

	public void save(RResumebasictable transientInstance) {
		log.debug("saving RResumebasictable instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(RResumebasictable persistentInstance) {
		log.debug("deleting RResumebasictable instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public RResumebasictable findById(java.lang.Integer id) {
		log.debug("getting RResumebasictable instance with id: " + id);
		try {
			RResumebasictable instance = (RResumebasictable) getSession().get(
					"com.comm.db.pojo.RResumebasictable", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(RResumebasictable instance) {
		log.debug("finding RResumebasictable instance by example");
		try {
			List results = getSession()
					.createCriteria("com.comm.db.pojo.RResumebasictable")
					.add(Example.create(instance)).list();
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding RResumebasictable instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from RResumebasictable as model where model."
					+ propertyName + "= ?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setParameter(0, value);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByUserId(Object userId) {
		return findByProperty(USER_ID, userId);
	}

	public List findByUserName(Object userName) {
		return findByProperty(USER_NAME, userName);
	}

	public List findByBirthDay(Object birthDay) {
		return findByProperty(BIRTH_DAY, birthDay);
	}

	public List findByAge(Object age) {
		return findByProperty(AGE, age);
	}

	public List findByMarried(Object married) {
		return findByProperty(MARRIED, married);
	}

	public List findByExperienceTimeVal(Object experienceTimeVal) {
		return findByProperty(EXPERIENCE_TIME_VAL, experienceTimeVal);
	}

	public List findByHighestDegree(Object highestDegree) {
		return findByProperty(HIGHEST_DEGREE, highestDegree);
	}

	public List findByAddress(Object address) {
		return findByProperty(ADDRESS, address);
	}

	public List findByCountry(Object country) {
		return findByProperty(COUNTRY, country);
	}

	public List findByNationality(Object nationality) {
		return findByProperty(NATIONALITY, nationality);
	}

	public List findByHomePhone(Object homePhone) {
		return findByProperty(HOME_PHONE, homePhone);
	}

	public List findByCompanyPhone(Object companyPhone) {
		return findByProperty(COMPANY_PHONE, companyPhone);
	}

	public List findByMsnorqq(Object msnorqq) {
		return findByProperty(MSNORQQ, msnorqq);
	}

	public List findByEmail(Object email) {
		return findByProperty(EMAIL, email);
	}

	public List findByHobbies(Object hobbies) {
		return findByProperty(HOBBIES, hobbies);
	}

	public List findByPrize(Object prize) {
		return findByProperty(PRIZE, prize);
	}

	public List findByJobInterest(Object jobInterest) {
		return findByProperty(JOB_INTEREST, jobInterest);
	}

	public List findByCertificateName(Object certificateName) {
		return findByProperty(CERTIFICATE_NAME, certificateName);
	}

	public List findByIndustryName(Object industryName) {
		return findByProperty(INDUSTRY_NAME, industryName);
	}

	public List findByLanguageName(Object languageName) {
		return findByProperty(LANGUAGE_NAME, languageName);
	}

	public List findByMajorName(Object majorName) {
		return findByProperty(MAJOR_NAME, majorName);
	}

	public List findByPositionName(Object positionName) {
		return findByProperty(POSITION_NAME, positionName);
	}

	public List findByFillUserId(Object fillUserId) {
		return findByProperty(FILL_USER_ID, fillUserId);
	}

	public List findByFillUser(Object fillUser) {
		return findByProperty(FILL_USER, fillUser);
	}

	public List findByLastEditUserId(Object lastEditUserId) {
		return findByProperty(LAST_EDIT_USER_ID, lastEditUserId);
	}

	public List findByLastEditUser(Object lastEditUser) {
		return findByProperty(LAST_EDIT_USER, lastEditUser);
	}

	public List findByFillDate(Object fillDate) {
		return findByProperty(FILL_DATE, fillDate);
	}

	public List findByLastEditTime(Object lastEditTime) {
		return findByProperty(LAST_EDIT_TIME, lastEditTime);
	}

	public List findByDelTag(Object delTag) {
		return findByProperty(DEL_TAG, delTag);
	}

	public List findByResumeLock(Object resumeLock) {
		return findByProperty(RESUME_LOCK, resumeLock);
	}

	public List findByCompanyName(Object companyName) {
		return findByProperty(COMPANY_NAME, companyName);
	}

	public List findByCurrentCompanyinfo(Object currentCompanyinfo) {
		return findByProperty(CURRENT_COMPANYINFO, currentCompanyinfo);
	}

	public List findByCvid(Object cvid) {
		return findByProperty(CVID, cvid);
	}

	public List findByCerttype(Object certtype) {
		return findByProperty(CERTTYPE, certtype);
	}

	public List findByCertno(Object certno) {
		return findByProperty(CERTNO, certno);
	}

	public List findByMobile(Object mobile) {
		return findByProperty(MOBILE, mobile);
	}

	public List findByFromId(Object fromId) {
		return findByProperty(FROM_ID, fromId);
	}

	public List findByCurrentSalary(Object currentSalary) {
		return findByProperty(CURRENT_SALARY, currentSalary);
	}

	public List findByWorkExperience(Object workExperience) {
		return findByProperty(WORK_EXPERIENCE, workExperience);
	}

	public List findByEdu(Object edu) {
		return findByProperty(EDU, edu);
	}

	public List findByLanguageSkill(Object languageSkill) {
		return findByProperty(LANGUAGE_SKILL, languageSkill);
	}

	public List findByItSkill(Object itSkill) {
		return findByProperty(IT_SKILL, itSkill);
	}

	public List findByProjectExperience(Object projectExperience) {
		return findByProperty(PROJECT_EXPERIENCE, projectExperience);
	}

	public List findBySelfAssessment(Object selfAssessment) {
		return findByProperty(SELF_ASSESSMENT, selfAssessment);
	}

	public List findByTrainer(Object trainer) {
		return findByProperty(TRAINER, trainer);
	}

	public List findByOthers(Object others) {
		return findByProperty(OTHERS, others);
	}

	public List findByResumeLanguage(Object resumeLanguage) {
		return findByProperty(RESUME_LANGUAGE, resumeLanguage);
	}

	public List findByWeibo(Object weibo) {
		return findByProperty(WEIBO, weibo);
	}

	public List findBySex(Object sex) {
		return findByProperty(SEX, sex);
	}

	public List findAll() {
		log.debug("finding all RResumebasictable instances");
		try {
			String queryString = "from RResumebasictable";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public RResumebasictable merge(RResumebasictable detachedInstance) {
		log.debug("merging RResumebasictable instance");
		try {
			RResumebasictable result = (RResumebasictable) getSession().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(RResumebasictable instance) {
		log.debug("attaching dirty RResumebasictable instance");
		try {
			getSession().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(RResumebasictable instance) {
		log.debug("attaching clean RResumebasictable instance");
		try {
			getSession().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}
	public static void main(String[] args) {
		ResumebasictableDAO dao=new ResumebasictableDAO();
		dao.findById(new Integer(2));
	}
}